package com.hnevc.cnlizhimaomxbc;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class SplashActivity extends AppCompatActivity {
    private ImageView sp_tu;
    private Button tz_bt;
    private Handler handler = new Handler();
    private Runnable runnableToLogin = new Runnable() {
        @Override
        public void run() {
           MainActivity();
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        initView();
        initEvent();
        handler.postDelayed(runnableToLogin,3000);
    }
    private void initView(){
        sp_tu =findViewById(R.id.sp_tu);
        tz_bt = findViewById(R.id.tz_bt);

    }
    private void initEvent(){
        sp_tu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                handler.removeCallbacks(runnableToLogin);
                MainActivity();
            }
        });
        tz_bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                handler.removeCallbacks(runnableToLogin);
                MainActivity();
            }
        });
    }
    private void MainActivity(){
        Intent intent = new Intent(SplashActivity.this,MainActivity.class);
        startActivity(intent);
        finish();
    }
}
